﻿using System;
using Microsoft.SharePoint;

namespace PD.ShP.Code
{
    /// <summary>
    /// Extensions for SPWeb member.
    /// </summary>
    public static class SPWebHelper
    {
        /// <summary>
        /// Returns the list that is associated with the specified site-relative URL.
        /// </summary>
        /// <param name="web">The web.</param>
        /// <param name="strUrl">A string that contains the site-relative URL for a list, for example, /Lists/Announcements.</param>
        /// <param name="isRelative">specify <c>true</c> when strUrl is relative.</param>
        /// <returns>List object.</returns>
        public static SPList GetList(this SPWeb web, string strUrl, bool isRelative)
        {
            if (isRelative)
            {
                return web.GetList(web.Url + "/" + strUrl);
            }
            else
            {
                return web.GetList(strUrl);
            }
        }
    }
}
